package com.aricksm.xuan.activity01;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

/**
 * Created by xuan on 16/6/15.
 */
public class IndexView extends Activity{

    Button goBtn;

    /**
     *
     * */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.index);

        goBtn = (Button) findViewById(R.id.btn_to_list);
        goBtn.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                //启动第二个view
                showView2();
            }
        });
    }

    //显示启动第二个avtivity
    public void showView1(){
        Intent intent = new Intent();
        intent.setClass(IndexView.this,ListView.class);
        intent.putExtra("title","女青年的故事");
        intent.putExtra("id",54);

        startActivity(intent);
    }

    //显示启动第二个avtivity
    public void showView2(){
        Intent intent = new Intent();
        intent.setClassName(IndexView.this,"com.aricksm.xuan.activity01.NewsListView");
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        Bundle bundle = new Bundle();
        bundle.putInt("id",89);
        bundle.putString("title","大学生创业");
        intent.putExtra("bundle",bundle);
        startActivity(intent);
    }

    //显示启动第二个avtivity
    public void showView3(){
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(IndexView.this ,UserInfoView.class));

        UserInfo user = new UserInfo();
        user.uid = 324;
        user.username = "xiaoming";
        user.age = 25;
        user.gender = 1;

        intent.putExtra("Serializable",user);

        startActivity(intent);
    }

    //显示启动第二个avtivity
    public void showView8(){
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(IndexView.this ,ListView.class));

        Order order = new Order();
        order.count = 500;
        order.address = "桥西区 中山东路59号";
        order.isReceived = false;


        intent.putExtra("order",order);

        startActivity(intent);
    }

    @Override
    public void startActivityForResult(Intent intent, int requestCode) {
        super.startActivityForResult(intent, requestCode);
    }

    @Override
    public void onActivityReenter(int resultCode, Intent data) {
        super.onActivityReenter(resultCode, data);
    }

    //隐式启动第二个avtivity
    public void showView4(){
        Intent intent = new Intent("abcd.List2");
        startActivity(intent);
    }

    //隐式启动第二个avtivity
    public void showView5(){
        Intent intent = new Intent();
        intent.setAction("List");
        startActivity(intent);
    }
}
